package com.airticketbooking.mapper;

import cn.hutool.core.date.DateTime;
import com.airticketbooking.common.domain.PageQuery;
import com.airticketbooking.po.User;
import com.airticketbooking.vo.UserPageVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;


@Mapper
public interface UserMapper {

	@Select("SELECT * FROM airticketbooking.user WHERE user_name = #{userName}")
	User getUserByUserName(String userName);

	@Insert("insert into airticketbooking.user(user_name, Email, phone_number, password,create_date,status)" +
			" values(#{userName},#{email},#{phoneNumber},#{password},#{createDate},#{status}) ")
	void add(User user);


	void update(User user);

	@Select("SELECT * FROM airticketbooking.user WHERE user_id = #{userId}")
	User getUserById(Integer userId);


	Page<UserPageVO> getUserByPage(PageQuery pageQuery);

	@Select("SELECT COUNT(*) FROM airticketbooking.user")
	Integer getAllUsers();

	Integer getUsersNumInRangeTime(org.joda.time.DateTime startTime, org.joda.time.DateTime endTime);
}
